package edu.sctu.zcy.month201505.day20150513;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by user24 on 2015/5/13.
 */
public class PersonMain {

    public static void main(String[] args) {

        Person[] persons;
        CalledPerson calledPerson = new CalledPerson();
        persons = calledPerson.print();

        SubClassOne subClassOne = new SubClassOne(persons);

//        System.out.println(i.get(0));
//        System.out.println((persons.length-i.size()+"个人未及格！"));


        System.out.println(subClassOne.printOne().size()+"个人及格\n");

        Iterator s = subClassOne.printOne().iterator();
        while (s.hasNext()){
            Person person = (Person)s.next();
            System.out.println(person.getName()+"  "+person.getScore()+"  "+person.getSex()+"  "+person.getAge()+
                    "  " +person.getAddress()+"  "+person.getNumber());
        }


        SubClassTwo subClassTwo = new SubClassTwo(persons);

        System.out.println(subClassTwo.printOne().size()+"个及格女生");
        Iterator s1 = subClassTwo.printOne().iterator();

        while (s1.hasNext()){
            Person person = (Person) s1.next();
            System.out.println();
            System.out.println(person.getName()+"  "+person.getScore()+"  "+person.getSex()+"  "+person.getAge()+
                    "  " +person.getAddress()+"  "+person.getNumber());

        }

        subClassOne.print(new InterFacePerson() {
                @Override
                public List<Person>  getInfo(int age) {
                    Person[] persons;
                    CalledPerson calledPerson = new CalledPerson();
                    persons = calledPerson.print();

                    List<Person> person = new ArrayList<Person>();

                    for (int i = 0; i <persons.length ; i++) {
                        if(persons[i].getAge() > age){
                            person.add(persons[i]);
                        }
                    }

                    return person;
                }
        });

    }


}
